package com.thti.mecool.client.command.result.communication;

import android.os.Bundle;
import android.os.Message;

import com.thti.mecool.client.activity.CommunicationActivity;
import com.thti.mecool.client.command.ICommand;
import com.thti.mecool.client.protocol.communication.CommunicationResult;
import com.thti.mecool.client.service.Protocol;
import com.thti.mecool.client.util.Util;

public class SearchCommunicationCommand implements ICommand{

	@Override
	public void doCommand(Object o) {
		CommunicationResult communicationResult=(CommunicationResult)o;
		if(communicationResult!=null){			
			if(communicationResult.getStatus()==1){
				int s=communicationResult.getPage().getTotalElement();
				Util.print(communicationResult.getPage().isHasNext());
				Util.print("sssssssssssssssss:  "+s);
				
				Message msg = new Message();
				msg.what=0xCD;
				Bundle bundle = new Bundle();
				bundle.putSerializable("comresult", communicationResult);
				msg.setData(bundle);
				CommunicationActivity.handler.sendMessage(msg);
				System.out.println( communicationResult.getType());
			}else{
				Message msg = new Message();
				msg.what=0xDD;
				Bundle bundle = new Bundle();
				bundle.putSerializable("msginfo", communicationResult.getMsg());
				msg.setData(bundle);
				CommunicationActivity.handler.sendMessage(msg);
				
				communicationResult.getMsg();
			}
		}
		
	}

	@Override
	public String getCommandID() {
		
		return Protocol.getCommunication;
	}

	@Override
	public Class<?> getCommandClass() {
		// TODO Auto-generated method stub
		return CommunicationResult.class;
	}

}
